# -*- coding:utf-8 -*-
from django import forms

class MessageForm(forms.Form):
    name = forms.CharField(label='姓名')
    content = forms.CharField(widget=forms.Textarea(),label='内容')
    imagefile = forms.ImageField(required=False,label='图片')
    savefile = forms.FileField(required=False,label='存档')

    def clean_savefile(self):
        savefile=self.cleaned_data.get('savefile','')
        if savefile:
            if str(savefile)[-3:].upper()!='SAV':
                raise forms.ValidationError("非存档文件!")
        return savefile
